package entity;

import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
public class StudentEntity {

    private String id;

    private String studentId;

    private String academyId;

    private String specialtyId;

    private String classId;

    private String name;

    private Integer gender;

    private Integer age;

    private String grade;

    private String degree;//学历

    public static StudentEntity mapToEntity(Map<String, Object> objectMap) {
        StudentEntity student = new StudentEntity();
        student.setId((String) objectMap.get("id"));
        student.setStudentId((String) objectMap.get("student_id"));
        student.setAcademyId((String) objectMap.get("academy_id"));
        student.setSpecialtyId((String) objectMap.get("specialty_id"));
        student.setClassId((String) objectMap.get("class_id"));
        student.setName((String) objectMap.get("name"));
        student.setGender((Integer) objectMap.get("gender"));
        student.setAge((Integer) objectMap.get("age"));
        student.setGrade((String) objectMap.get("grade"));
        student.setDegree((String) objectMap.get("degree"));
        return student;
    }

    public static List<StudentEntity> mapListToEntityList(List<Map<String, Object>> objectMapList) {
        return objectMapList.stream().map(StudentEntity::mapToEntity).collect(Collectors.toList());
    }
}
